<div class="page-wrapper d-flex flex-column pt-4">
    <div class="container-xl">
        <div class="page-header d-print-none">
            <div class="row align-items-center">
                <div class="col">
                    <div class="page-pretitle">
                        Listing
                    </div>
                    <h3 class="page-title">
                        All Permissions
                    </h3>
                </div>
            </div>
        </div>
    </div>
    <div class="page-body d-flex flex-row-reverse">

        <aside class="bd-sidebar sub-sidebar">
            <nav class="bd-links p-3" aria-label="Sub-section navigation">

                <div class="card card-body">
                    <filter-list request="request" callback="getList()" create-url="'/portal/permission/create'"
                        create-text="'Create Permission'"></filter-list>
                    <!-- TODO: Hoang to check search by level not work -->
                    <label class="form-label mt-3">Permission Level</label>
                    <input type="number" class="form-control mb-4" ng-enger="getList()" ng-model="request.level" />
                </div>
            </nav>
        </aside>


        <!-- ----------------------------------------------------------- -->


        <div class="content-body py-3 pe-3">


            <div class="card mb-5" ng-init="getList()">
                <div class="card-body">
                    <table id="list-page" class="table table-hover sortable" cellspacing="0" ng-init="getList()">
                        <thead class="thead-light">
                            <tr>
                                <th scope="col" style="width: 3%;">
                                    <!-- <small class="fa fa-grip-vertical fa-xs text-black-50 align-middle"></small> -->
                                </th>
                                <th scope="col" style="width: 4%;">
                                    <!-- <span class="fa fa-grip-vertical fa-xs text-black-50-numeric-down"></span> -->
                                </th>
                                <th scope="col" style="width: 25%;">
                                    Keyword
                                </th>
                                <th scope="col" style="width: 10%;">
                                    Default
                                </th>
                                </th>
                                <th scope="col" width="10%">
                                    Url
                                </th>
                                <th scope="col" width="10%">
                                    Created Date

                                <th scope="col" style="width: 5%;"></th>
                            </tr>
                        </thead>

                        <tbody class="sortable" dnd-list="data.items" dnd-disable-if="canDrag"
                            dnd-inserted="updateOrders(index)">
                            <!-- <tr ng-if="canDrag">
                        <td colspan="7"><small class="text-warning"
                                ng-bind="translate('warning_can_not_drag_drop',true, '(Drag & Drop feature only active when priority is asc)')"></small>
                        </td>
                    </tr> -->
                            <tr ng-repeat="item in data.items" dnd-draggable="item" dnd-selected="selected = item"
                                dnd-moved="updateInfos($index)" ng-class="{'selected': selected === item}"
                                dnd-effect-allowed="copyMove" dnd-selected="selected = item"
                                dnd-dragstart="dragStart($index)">
                                <td style="cursor:grab;" class="drag-header small">
                                    <small class="fa fa-grip-vertical fa-xs text-black-50 align-middle"></small>
                                </td>
                                <td>
                                    <input type="text" value="{{item.pageId}}"
                                        class="item-priority form-control form-control-sm d-inline" style="width:40px;">
                                </td>
                                <td class="small">
                                    <span ng-bind-html="item.textKeyword"></span>
                                </td>
                                <td>
                                    <span ng-bind-html="item.textDefault"></span>
                                </td>
                                <td class="small">
                                    <span ng-bind-html="item.url|trim:50"></span>
                                </td>
                                <td class="small">
                                    {{item.post.createdDateTime | utcToLocal:'dd.MM.yy hh:mm a'}}
                                </td>

                                <td>
                                    <div class="btn-group btn-group-sm btn-group-sm float-end" role="group"
                                        aria-label="Actions">
                                        <a ng-click="goToPath('/portal/permission/details/' + item.id)"
                                            class="btn btn-link text-primary">
                                            <span class="fas fa-pen"></span>
                                        </a>
                                        <a ng-click="remove(item.id);" class="btn btn-link text-danger">
                                            <span class="fas fa-trash-alt"></span>
                                        </a>
                                    </div>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="">
                <paging class="small" page="data.page" page-size="data.pageSize" total="data.totalItems"
                    ul-class="pagination justify-content-end m-0" a-class="page-link"
                    paging-action="loadProducts(page-1)" scroll-top="true">
            </div>

        </div>

    </div>
</div>